//
//  ZBTabbarViewController.m
//  私教学车
//
//  Created by 亿拓普 on 16/5/13.
//  Copyright © 2016年 亿拓普. All rights reserved.
//

#import "HomeC.h"
#import "CustomC.h"
#import "HousingResourceC.h"
#import "MineC.h"
#import "LGBaseViewController.h"
#import "ZBTabbarViewController.h"
#import "BONaviViewController.h"


@interface ZBTabbarViewController () <UITabBarControllerDelegate>


@end



@implementation ZBTabbarViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.delegate = self;
    
    HomeC *home = [[HomeC alloc] init];
    [self addChildVc:home title:@"首页" image:@"curriculum_408" selectedImage:@"curriculum_selected_408"];
    
    CustomC *past1 = [[CustomC alloc] init];
    [self addChildVc:past1 title:@"客户" image:@"examination_408" selectedImage:@"examination_selected_408"];
    
    HousingResourceC *interActionC = [[HousingResourceC alloc] init];
    [self addChildVc:interActionC title:@"房源" image:@"student_408" selectedImage:@"student_selected_408"];
    
    MineC *my = [[MineC alloc] init];
    [self addChildVc:my title:@"我的" image:@"information_408" selectedImage:@"information_selected_408"];

    // 设置背景颜色
//    [my.tabBarController.tabBar setBarTintColor:[UIColor whiteColor]];
//    [my.tabBarController.tabBar setAlpha:0.9];
    
    // 设置tabbar不透明
    self.tabBar.translucent = NO;
    
}


- (void)addChildVc:(UIViewController *)childVc title:(NSString *)title image:(NSString *)image selectedImage:(NSString *)selectedImage
{
    // 设置标题
    childVc.title = title;
    // 设置图片
    childVc.tabBarItem.image = [[UIImage imageNamed:image] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    childVc.tabBarItem.selectedImage = [[UIImage imageNamed:selectedImage] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    
    // 设置文字样式
    NSMutableDictionary *textAttrs = [NSMutableDictionary dictionary];
    textAttrs[NSForegroundColorAttributeName] = [UIColor lightGrayColor];
    NSMutableDictionary *selectTextAttrs = [NSMutableDictionary dictionary];
    selectTextAttrs[NSForegroundColorAttributeName] = [UIColor blueColor];
    [childVc.tabBarItem setTitleTextAttributes:textAttrs forState:UIControlStateNormal];
    [childVc.tabBarItem setTitleTextAttributes:selectTextAttrs forState:UIControlStateSelected];
    
    // 给外面传进来的控制器包装一个导航控制器
    BONaviViewController *nav = [[BONaviViewController alloc] initWithRootViewController:childVc];
    [self addChildViewController:nav];
}

@end
